﻿@model IEnumerable<CTM.Web.Models.View.Feedback.FeedbackViewModel>
@using CTM.Web.Utils
@foreach (var feedback in Model)
{
    <a href="javascript: void(0);" class="list-group-item" id="feedback-@feedback.Id" onclick="viewContent('@feedback.Id')">
        <div class="row">
            <div class="col-xs-12 col-sm-2 hidden-xs">
                <img class="img-responsive user-avatar" src="@feedback.Manager.Avatar" style="width: 100%; height: auto;" />
            </div>
            <div class="col-xs-12 col-sm-10">
                <div class="row">
                    <div class="col-xs-12 col-sm-8">
                        <div class="media">
                            <div class="media-left hidden-sm hidden-md hidden-lg">
                                <img alt="64x64" class="media-object" style="width: 28px; height: 28px;" src="@feedback.Manager.Avatar" />
                            </div>
                            <div class="media-body">
                                <div class="row">
                                    <div class="col-xs-12">
                                        <span class="fa fa-user"></span> @feedback.Manager.DisplayName
                                    </div>
                                    <div class="col-xs-12">
                                        <span class="fa fa-calendar"></span> @feedback.CreatedOn.ToString("dd-MMM-yyyy HH:mm")
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 feedback-tags">
                                <input type="hidden" value="@string.Join(",", feedback.Tags.Select(t => t.Name))" />
                                @foreach (var tag in feedback.Tags)
                                {
                                    <span class="label label-default tags">@tag.Name</span>
                                }
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-4 text-right">
                        @if (feedback.IsPrivate)
                        {
                            <button type="button" class="btn btn-xs hidden-xs bg-grey-silver">
                                <span class="fa fa-lock"></span>
                            </button>
                        }
                        @if (feedback.Manager.Id == GlobalVariables.CurrentUser.Id)
                        {
                            <button type="button" class="btn btn-info btn-xs hidden-xs" data-target=".modal-feedback" data-toggle="modal" data-feedback-id="@feedback.Id">
                                <span class="fa fa-pencil"></span>
                            </button>
                            <button type="button" class="btn btn-danger btn-xs rbvh-btn-remove-feedback hidden-xs" data-toggle="modal" data-target="#DeleteFeedbackModal" data-feedback-id="@feedback.Id">
                                <span class="fa fa-trash"></span>
                            </button>
                        }
                    </div>
                </div>
                <h5>
                    <input type="hidden" class="feedback-emoticon" value="@feedback.Emoticon" />
                    <strong>
                        @switch (feedback.Emoticon)
                        {
                            case CTM.Web.Utils.Emoticon.Smile:
                                <span class="fa fa-smile-o text-success"></span>
                                break;
                            case CTM.Web.Utils.Emoticon.Neutral:
                            <span class="fa fa-meh-o text-warning"></span>
                                break;
                            case CTM.Web.Utils.Emoticon.Frown:
                            <span class="fa fa-frown-o text-danger"></span>
                                break;
                        }
                    </strong>
                    &mdash;<span class="feedback-description">@Html.Raw(Html.Encode(feedback.Description).Replace("\n", "<br/>"))</span>
                </h5>
                <input type="hidden" class="feedback-isprivate" value="@feedback.IsPrivate.ToString()" @Html.Raw(feedback.IsPrivate ? "checked='checked'" : string.Empty) />
                @if (GlobalVariables.CurrentUser.Id == feedback.CreatedBy || (GlobalVariables.CurrentUser.Id == GlobalVariables.SelectedUser.Id && !feedback.IsPrivate))
                {
                    <button type="button" class="btn btn-warning btn-xs hidden-sm hidden-md hidden-lg" data-target=".modal-feedback" data-toggle="modal" data-feedback-id="@feedback.Id">Edit</button>
                    <button type="button" class="btn btn-danger btn-xs hidden-sm rbvh-btn-remove-feedback hidden-md hidden-lg" data-toggle="modal" data-target="#DeleteFeedbackModal" data-feedback-id="@feedback.Id">Delete</button>
                }
            </div>
        </div>
    </a>
}